package com.ruoyi.system.service.impl;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.system.domain.ChatLog;
import com.ruoyi.system.domain.ChatMessages;
import com.ruoyi.system.mapper.ChatLogMapper;
import com.ruoyi.system.mapper.CommomQaMapper;
import com.ruoyi.system.service.ICommomQaService;
import com.ruoyi.system.service.iChatLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChatLogServiceImpl implements iChatLogService {

    @Autowired
    private ChatLogMapper chatLogMapper;

    @Autowired(required = false)
    RedisCache redisCache;
    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public List<ChatLog> selectChatLogList(ChatLog chatLog) {
        List<ChatLog> log = chatLogMapper.selectChatLogList(chatLog);
        //怎么设计返回时，判断userType = 1，翻译 text
        return log;
    }

    @Override
    public List<ChatLog> selectChatLog(String customerNumber, String clientNumber) {
        return null;
    }

    @Override
    public List<ChatLog> selectChatByMaxTime(ChatLog chatLog) {
        return chatLogMapper.selectChatByMaxTime(chatLog);
    }

    @Override
    public List<ChatMessages> getMessagesByFansId(String clientNumber) {

        String key = "persona:fans:" + clientNumber + ":unread";
        redisCache.setCacheObject(key,0);
        return chatLogMapper.getMessagesByFansId(clientNumber);
    }
}
